
#include "EmitterBase.hpp"

EmitterBase::EmitterBase(void)
{
}

EmitterBase::EmitterBase(std::list<ParticleBase*> *particles, float posX, float posY, PixelBuffer *texture)
{
	// receives poninter to particle list
	this->particles = particles;

	// init position
	x = posX;
	y = posY;

	// copy poninter
	this->texture = texture;
}

EmitterBase::~EmitterBase(void)
{
}

void EmitterBase::SetPos(float _x, float _y)
{
	x = _x;
	y = _y;
}

void EmitterBase::Update()
{
	int posX, posY;
	posX = (screen.width-((rand())%(screen.width*2 + 1))) + x; 
	posY = (screen.width-((rand())%(screen.width*2 + 1))) + y;

	// create one particle per frame
	ParticleBase * temp = new ParticleBase();

	temp->ConfigParticle(posX, posY, 0, texture);
	particles->push_back(temp); // add on the list
}